//
//  AIFAccountUnbindFromPassportManager.m
//  PywSdk
//
//  Created by smallwave on 16/8/31.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFAccountUnbindFromPassportManager.h"
#import "PywRSAUtil.h"

@implementation AIFAccountUnbindFromPassportManager

NSString *const AccountUnbindFromPassport_SIGN = @"sign";
NSString *const AccountUnbindFromPassport_GAMEID = @"gameid";
NSString *const AccountUnbindFromPassport_TID = @"tid";
NSString *const AccountUnbindFromPassport_ACCOUNT = @"account";
NSString *const AccountUnbindFromPassport_ACCOUNT_PWD = @"account_pwd";
NSString *const AccountUnbindFromPassport_PASSPORT_TOKEN = @"passport_token";
NSString *const AccountUnbindFromPassport_PASSPORT = @"passport";

- (instancetype)init{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}

#pragma mark - ETAPIManager
- (NSString *)methodName{
    return URL_ACCOUNTUNBINDFROMPASSPORT;
}

- (ETAPIManagerRequestType)requestType{
    return ETAPIManagerRequestTypePost;
}


- (NSString *)seriviceType{
    return [PywAppInfo sharedAppInfo].seriviceType;
}


#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager{
    
    NSString *passport = [PywPlatformMain sharedPlatformMain].passport;
    NSString *passport_token = [PywPlatformMain sharedPlatformMain].passport_Token;
    
    NSString *gameid = [PywAppInfo sharedAppInfo].gameId;
    NSString *account = self.account;
    NSString *account_pwd = [PywRSAUtil encryptString:self.account_pwd];
    
    NSString *tid = [PywAppInfo sharedAppInfo].tid;
    NSString *apiSecret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",passport,account,apiSecret2];
    sign = [PywCipherUtils md5:sign];
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    [param setObject:sign forKey:AccountUnbindFromPassport_SIGN];
    [param setObject:tid forKey:AccountUnbindFromPassport_TID];
    [param setObject:gameid forKey:AccountUnbindFromPassport_GAMEID];
    [param setObject:account forKey:AccountUnbindFromPassport_ACCOUNT];
    [param setObject:account_pwd forKey:AccountUnbindFromPassport_ACCOUNT_PWD];
    [param setObject:passport forKey:AccountUnbindFromPassport_PASSPORT];
    [param setObject:passport_token forKey:AccountUnbindFromPassport_PASSPORT_TOKEN];
    return param;
}

#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}

@end
